{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# <center>零售业数据分析系</center>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "项目背景\n",
    "- 此次项目数据来自Kaggle，包含了2010年12月1日至2011年12月9日在英国注册的非实体网上零售发生的所有交易。公司主要销售独特的全天候礼品。该公司的许多客户都是批发商。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 字段介绍\n",
    "- InvoiceNo: 订单编号，每笔交易有6个整数，退货订单编号开头有字母'C'。\n",
    "- StockCode: 产品编号，由5个整数组成。\n",
    "- Description: 产品描述。\n",
    "- Quantity: 产品数量，有负号的表示退货\n",
    "- InvoiceDate: 订单日期和时间。\n",
    "- UnitPrice: 单价（英镑），单位产品的价格。\n",
    "- CustomerID:客户编号，每个客户编号由5位数字组成。\n",
    "- Country: 国家的名称，每个客户所在国家/地区的名称。\n",
    "\n",
    "> 问题\n",
    "- 1.购买商品数前十的国家是？\n",
    "- 2.交易额前十的国家是？\n",
    "- 3.哪些月份销量较佳？\n",
    "- 4.客单价多少？\n",
    "- 5.用户消费行为分析"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 导入数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Bar, Grid, Line,Scatter,Pie,Funnel\n",
    "#LIGHT DARK CHALK ESSOS PURPLE_PASSION\n",
    "from pyecharts.globals import ThemeType\n",
    "\n",
    "import json\n",
    "from pandas.io.json import json_normalize\n",
    "#设置中文标签的显示\n",
    "plt.rcParams['font.sans-serif'] = ['SimHei']  #设置显示中文字体"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编号</th>\n",
       "      <th>产品编号</th>\n",
       "      <th>产品描述</th>\n",
       "      <th>产品数量</th>\n",
       "      <th>订单日期和时间</th>\n",
       "      <th>单价（英镑）</th>\n",
       "      <th>客户编号</th>\n",
       "      <th>国家的名称</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>InvoiceNo</td>\n",
       "      <td>StockCode</td>\n",
       "      <td>Description</td>\n",
       "      <td>Quantity</td>\n",
       "      <td>InvoiceDate</td>\n",
       "      <td>UnitPrice</td>\n",
       "      <td>CustomerID</td>\n",
       "      <td>Country</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>536365</td>\n",
       "      <td>85123A</td>\n",
       "      <td>WHITE HANGING HEART T-LIGHT HOLDER</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>2.55</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>536365</td>\n",
       "      <td>71053</td>\n",
       "      <td>WHITE METAL LANTERN</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>3.39</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>536365</td>\n",
       "      <td>84406B</td>\n",
       "      <td>CREAM CUPID HEARTS COAT HANGER</td>\n",
       "      <td>8</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>2.75</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>536365</td>\n",
       "      <td>84029G</td>\n",
       "      <td>KNITTED UNION FLAG HOT WATER BOTTLE</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>3.39</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541905</th>\n",
       "      <td>581587</td>\n",
       "      <td>22613</td>\n",
       "      <td>PACK OF 20 SPACEBOY NAPKINS</td>\n",
       "      <td>12</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>0.85</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541906</th>\n",
       "      <td>581587</td>\n",
       "      <td>22899</td>\n",
       "      <td>CHILDREN'S APRON DOLLY GIRL</td>\n",
       "      <td>6</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>2.1</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541907</th>\n",
       "      <td>581587</td>\n",
       "      <td>23254</td>\n",
       "      <td>CHILDRENS CUTLERY DOLLY GIRL</td>\n",
       "      <td>4</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.15</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541908</th>\n",
       "      <td>581587</td>\n",
       "      <td>23255</td>\n",
       "      <td>CHILDRENS CUTLERY CIRCUS PARADE</td>\n",
       "      <td>4</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.15</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541909</th>\n",
       "      <td>581587</td>\n",
       "      <td>22138</td>\n",
       "      <td>BAKING SET 9 PIECE RETROSPOT</td>\n",
       "      <td>3</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.95</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>541910 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             订单编号       产品编号                                 产品描述      产品数量  \\\n",
       "0       InvoiceNo  StockCode                          Description  Quantity   \n",
       "1          536365     85123A   WHITE HANGING HEART T-LIGHT HOLDER         6   \n",
       "2          536365      71053                  WHITE METAL LANTERN         6   \n",
       "3          536365     84406B       CREAM CUPID HEARTS COAT HANGER         8   \n",
       "4          536365     84029G  KNITTED UNION FLAG HOT WATER BOTTLE         6   \n",
       "...           ...        ...                                  ...       ...   \n",
       "541905     581587      22613          PACK OF 20 SPACEBOY NAPKINS        12   \n",
       "541906     581587      22899         CHILDREN'S APRON DOLLY GIRL          6   \n",
       "541907     581587      23254        CHILDRENS CUTLERY DOLLY GIRL          4   \n",
       "541908     581587      23255      CHILDRENS CUTLERY CIRCUS PARADE         4   \n",
       "541909     581587      22138        BAKING SET 9 PIECE RETROSPOT          3   \n",
       "\n",
       "                订单日期和时间     单价（英镑）        客户编号           国家的名称  \n",
       "0           InvoiceDate  UnitPrice  CustomerID         Country  \n",
       "1        12/1/2010 8:26       2.55     17850.0  United Kingdom  \n",
       "2        12/1/2010 8:26       3.39     17850.0  United Kingdom  \n",
       "3        12/1/2010 8:26       2.75     17850.0  United Kingdom  \n",
       "4        12/1/2010 8:26       3.39     17850.0  United Kingdom  \n",
       "...                 ...        ...         ...             ...  \n",
       "541905  12/9/2011 12:50       0.85     12680.0          France  \n",
       "541906  12/9/2011 12:50        2.1     12680.0          France  \n",
       "541907  12/9/2011 12:50       4.15     12680.0          France  \n",
       "541908  12/9/2011 12:50       4.15     12680.0          France  \n",
       "541909  12/9/2011 12:50       4.95     12680.0          France  \n",
       "\n",
       "[541910 rows x 8 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "film_date=pd.read_csv(\"data.csv\",header=None,encoding=\"utf-8\",dtype = {'Country' : str,\"Quantity\":np.int64},names=['订单编号','产品编号','产品描述','产品数量','订单日期和时间','单价（英镑）','客户编号','国家的名称'],low_memory=False)\n",
    "film_date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编号</th>\n",
       "      <th>产品编号</th>\n",
       "      <th>产品描述</th>\n",
       "      <th>产品数量</th>\n",
       "      <th>订单日期和时间</th>\n",
       "      <th>单价（英镑）</th>\n",
       "      <th>客户编号</th>\n",
       "      <th>国家的名称</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>InvoiceNo</td>\n",
       "      <td>StockCode</td>\n",
       "      <td>Description</td>\n",
       "      <td>Quantity</td>\n",
       "      <td>InvoiceDate</td>\n",
       "      <td>UnitPrice</td>\n",
       "      <td>CustomerID</td>\n",
       "      <td>Country</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>536365</td>\n",
       "      <td>85123A</td>\n",
       "      <td>WHITE HANGING HEART T-LIGHT HOLDER</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>2.55</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>536365</td>\n",
       "      <td>71053</td>\n",
       "      <td>WHITE METAL LANTERN</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>3.39</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>536365</td>\n",
       "      <td>84406B</td>\n",
       "      <td>CREAM CUPID HEARTS COAT HANGER</td>\n",
       "      <td>8</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>2.75</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>536365</td>\n",
       "      <td>84029G</td>\n",
       "      <td>KNITTED UNION FLAG HOT WATER BOTTLE</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>3.39</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541905</th>\n",
       "      <td>581587</td>\n",
       "      <td>22613</td>\n",
       "      <td>PACK OF 20 SPACEBOY NAPKINS</td>\n",
       "      <td>12</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>0.85</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541906</th>\n",
       "      <td>581587</td>\n",
       "      <td>22899</td>\n",
       "      <td>CHILDREN'S APRON DOLLY GIRL</td>\n",
       "      <td>6</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>2.1</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541907</th>\n",
       "      <td>581587</td>\n",
       "      <td>23254</td>\n",
       "      <td>CHILDRENS CUTLERY DOLLY GIRL</td>\n",
       "      <td>4</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.15</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541908</th>\n",
       "      <td>581587</td>\n",
       "      <td>23255</td>\n",
       "      <td>CHILDRENS CUTLERY CIRCUS PARADE</td>\n",
       "      <td>4</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.15</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541909</th>\n",
       "      <td>581587</td>\n",
       "      <td>22138</td>\n",
       "      <td>BAKING SET 9 PIECE RETROSPOT</td>\n",
       "      <td>3</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.95</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>406830 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             订单编号       产品编号                                 产品描述      产品数量  \\\n",
       "0       InvoiceNo  StockCode                          Description  Quantity   \n",
       "1          536365     85123A   WHITE HANGING HEART T-LIGHT HOLDER         6   \n",
       "2          536365      71053                  WHITE METAL LANTERN         6   \n",
       "3          536365     84406B       CREAM CUPID HEARTS COAT HANGER         8   \n",
       "4          536365     84029G  KNITTED UNION FLAG HOT WATER BOTTLE         6   \n",
       "...           ...        ...                                  ...       ...   \n",
       "541905     581587      22613          PACK OF 20 SPACEBOY NAPKINS        12   \n",
       "541906     581587      22899         CHILDREN'S APRON DOLLY GIRL          6   \n",
       "541907     581587      23254        CHILDRENS CUTLERY DOLLY GIRL          4   \n",
       "541908     581587      23255      CHILDRENS CUTLERY CIRCUS PARADE         4   \n",
       "541909     581587      22138        BAKING SET 9 PIECE RETROSPOT          3   \n",
       "\n",
       "                订单日期和时间     单价（英镑）        客户编号           国家的名称  \n",
       "0           InvoiceDate  UnitPrice  CustomerID         Country  \n",
       "1        12/1/2010 8:26       2.55     17850.0  United Kingdom  \n",
       "2        12/1/2010 8:26       3.39     17850.0  United Kingdom  \n",
       "3        12/1/2010 8:26       2.75     17850.0  United Kingdom  \n",
       "4        12/1/2010 8:26       3.39     17850.0  United Kingdom  \n",
       "...                 ...        ...         ...             ...  \n",
       "541905  12/9/2011 12:50       0.85     12680.0          France  \n",
       "541906  12/9/2011 12:50        2.1     12680.0          France  \n",
       "541907  12/9/2011 12:50       4.15     12680.0          France  \n",
       "541908  12/9/2011 12:50       4.15     12680.0          France  \n",
       "541909  12/9/2011 12:50       4.95     12680.0          France  \n",
       "\n",
       "[406830 rows x 8 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#查看各行的控制情况\n",
    "film_date.isnull().any(axis=0)\n",
    "#删除存在的空行数据\n",
    "film_date.dropna(axis=0,how='any',inplace=True)\n",
    "\n",
    "film_date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编号</th>\n",
       "      <th>产品编号</th>\n",
       "      <th>产品描述</th>\n",
       "      <th>产品数量</th>\n",
       "      <th>订单日期和时间</th>\n",
       "      <th>单价（英镑）</th>\n",
       "      <th>客户编号</th>\n",
       "      <th>国家的名称</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>536365</td>\n",
       "      <td>71053</td>\n",
       "      <td>WHITE METAL LANTERN</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>3.39</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>536365</td>\n",
       "      <td>22752</td>\n",
       "      <td>SET 7 BABUSHKA NESTING BOXES</td>\n",
       "      <td>2</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>7.65</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>536365</td>\n",
       "      <td>21730</td>\n",
       "      <td>GLASS STAR FROSTED T-LIGHT HOLDER</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:26</td>\n",
       "      <td>4.25</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>536366</td>\n",
       "      <td>22633</td>\n",
       "      <td>HAND WARMER UNION JACK</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:28</td>\n",
       "      <td>1.85</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>536366</td>\n",
       "      <td>22632</td>\n",
       "      <td>HAND WARMER RED POLKA DOT</td>\n",
       "      <td>6</td>\n",
       "      <td>12/1/2010 8:28</td>\n",
       "      <td>1.85</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541905</th>\n",
       "      <td>581587</td>\n",
       "      <td>22613</td>\n",
       "      <td>PACK OF 20 SPACEBOY NAPKINS</td>\n",
       "      <td>12</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>0.85</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541906</th>\n",
       "      <td>581587</td>\n",
       "      <td>22899</td>\n",
       "      <td>CHILDREN'S APRON DOLLY GIRL</td>\n",
       "      <td>6</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>2.1</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541907</th>\n",
       "      <td>581587</td>\n",
       "      <td>23254</td>\n",
       "      <td>CHILDRENS CUTLERY DOLLY GIRL</td>\n",
       "      <td>4</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.15</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541908</th>\n",
       "      <td>581587</td>\n",
       "      <td>23255</td>\n",
       "      <td>CHILDRENS CUTLERY CIRCUS PARADE</td>\n",
       "      <td>4</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.15</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541909</th>\n",
       "      <td>581587</td>\n",
       "      <td>22138</td>\n",
       "      <td>BAKING SET 9 PIECE RETROSPOT</td>\n",
       "      <td>3</td>\n",
       "      <td>12/9/2011 12:50</td>\n",
       "      <td>4.95</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>371020 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          订单编号   产品编号                               产品描述 产品数量  \\\n",
       "2       536365  71053                WHITE METAL LANTERN    6   \n",
       "6       536365  22752       SET 7 BABUSHKA NESTING BOXES    2   \n",
       "7       536365  21730  GLASS STAR FROSTED T-LIGHT HOLDER    6   \n",
       "8       536366  22633             HAND WARMER UNION JACK    6   \n",
       "9       536366  22632          HAND WARMER RED POLKA DOT    6   \n",
       "...        ...    ...                                ...  ...   \n",
       "541905  581587  22613        PACK OF 20 SPACEBOY NAPKINS   12   \n",
       "541906  581587  22899       CHILDREN'S APRON DOLLY GIRL     6   \n",
       "541907  581587  23254      CHILDRENS CUTLERY DOLLY GIRL     4   \n",
       "541908  581587  23255    CHILDRENS CUTLERY CIRCUS PARADE    4   \n",
       "541909  581587  22138      BAKING SET 9 PIECE RETROSPOT     3   \n",
       "\n",
       "                订单日期和时间 单价（英镑）     客户编号           国家的名称  \n",
       "2        12/1/2010 8:26   3.39  17850.0  United Kingdom  \n",
       "6        12/1/2010 8:26   7.65  17850.0  United Kingdom  \n",
       "7        12/1/2010 8:26   4.25  17850.0  United Kingdom  \n",
       "8        12/1/2010 8:28   1.85  17850.0  United Kingdom  \n",
       "9        12/1/2010 8:28   1.85  17850.0  United Kingdom  \n",
       "...                 ...    ...      ...             ...  \n",
       "541905  12/9/2011 12:50   0.85  12680.0          France  \n",
       "541906  12/9/2011 12:50    2.1  12680.0          France  \n",
       "541907  12/9/2011 12:50   4.15  12680.0          France  \n",
       "541908  12/9/2011 12:50   4.15  12680.0          France  \n",
       "541909  12/9/2011 12:50   4.95  12680.0          France  \n",
       "\n",
       "[371020 rows x 8 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 产品编号---保证产品编号是5位纯数字\n",
    "film_date=film_date[film_date.loc[:,'产品编号'].apply(lambda x: x.isdigit())]\n",
    "\n",
    "# film_date=film_date[film_date[\"产品编号\"].apply(lambda x: x.isdigit())]\n",
    "film_date\n",
    "# film_date\n",
    "# film_date.to_csv(\"shuju.csv\",encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\program files\\python\\lib\\site-packages\\pandas\\core\\indexing.py:1781: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  self.obj[item_labels[indexer[info_axis]]] = value\n",
      "d:\\program files\\python\\lib\\site-packages\\pandas\\core\\indexing.py:1743: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  isetter(ilocs[0], value)\n"
     ]
    }
   ],
   "source": [
    "#对日期数据进行处理\n",
    "film_date.loc[:,'订单日期和时间']=pd.to_datetime(film_date['订单日期和时间'], format='%m/%d/%Y %H:%M')\n",
    "#对产品数量的数据类型进行处理\n",
    "\n",
    "film_date.loc[:,\"产品数量\"]=film_date[\"产品数量\"].astype(np.int64)\n",
    "# film_date.loc[:,\"国家的名称\"]=film_date[\"国家的名称\"].astype(np.string_)\n",
    "# film_date.to_csv(\"shuju.csv\",encoding='gbk')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编号</th>\n",
       "      <th>产品编号</th>\n",
       "      <th>产品描述</th>\n",
       "      <th>产品数量</th>\n",
       "      <th>订单日期和时间</th>\n",
       "      <th>单价（英镑）</th>\n",
       "      <th>客户编号</th>\n",
       "      <th>国家的名称</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>536365</td>\n",
       "      <td>71053</td>\n",
       "      <td>WHITE METAL LANTERN</td>\n",
       "      <td>6</td>\n",
       "      <td>2010-12-01 08:26:00</td>\n",
       "      <td>3.39</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>536365</td>\n",
       "      <td>22752</td>\n",
       "      <td>SET 7 BABUSHKA NESTING BOXES</td>\n",
       "      <td>2</td>\n",
       "      <td>2010-12-01 08:26:00</td>\n",
       "      <td>7.65</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>536365</td>\n",
       "      <td>21730</td>\n",
       "      <td>GLASS STAR FROSTED T-LIGHT HOLDER</td>\n",
       "      <td>6</td>\n",
       "      <td>2010-12-01 08:26:00</td>\n",
       "      <td>4.25</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>536366</td>\n",
       "      <td>22633</td>\n",
       "      <td>HAND WARMER UNION JACK</td>\n",
       "      <td>6</td>\n",
       "      <td>2010-12-01 08:28:00</td>\n",
       "      <td>1.85</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>536366</td>\n",
       "      <td>22632</td>\n",
       "      <td>HAND WARMER RED POLKA DOT</td>\n",
       "      <td>6</td>\n",
       "      <td>2010-12-01 08:28:00</td>\n",
       "      <td>1.85</td>\n",
       "      <td>17850.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541905</th>\n",
       "      <td>581587</td>\n",
       "      <td>22613</td>\n",
       "      <td>PACK OF 20 SPACEBOY NAPKINS</td>\n",
       "      <td>12</td>\n",
       "      <td>2011-12-09 12:50:00</td>\n",
       "      <td>0.85</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541906</th>\n",
       "      <td>581587</td>\n",
       "      <td>22899</td>\n",
       "      <td>CHILDREN'S APRON DOLLY GIRL</td>\n",
       "      <td>6</td>\n",
       "      <td>2011-12-09 12:50:00</td>\n",
       "      <td>2.1</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541907</th>\n",
       "      <td>581587</td>\n",
       "      <td>23254</td>\n",
       "      <td>CHILDRENS CUTLERY DOLLY GIRL</td>\n",
       "      <td>4</td>\n",
       "      <td>2011-12-09 12:50:00</td>\n",
       "      <td>4.15</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541908</th>\n",
       "      <td>581587</td>\n",
       "      <td>23255</td>\n",
       "      <td>CHILDRENS CUTLERY CIRCUS PARADE</td>\n",
       "      <td>4</td>\n",
       "      <td>2011-12-09 12:50:00</td>\n",
       "      <td>4.15</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>541909</th>\n",
       "      <td>581587</td>\n",
       "      <td>22138</td>\n",
       "      <td>BAKING SET 9 PIECE RETROSPOT</td>\n",
       "      <td>3</td>\n",
       "      <td>2011-12-09 12:50:00</td>\n",
       "      <td>4.95</td>\n",
       "      <td>12680.0</td>\n",
       "      <td>France</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>371020 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          订单编号   产品编号                               产品描述  产品数量  \\\n",
       "2       536365  71053                WHITE METAL LANTERN     6   \n",
       "6       536365  22752       SET 7 BABUSHKA NESTING BOXES     2   \n",
       "7       536365  21730  GLASS STAR FROSTED T-LIGHT HOLDER     6   \n",
       "8       536366  22633             HAND WARMER UNION JACK     6   \n",
       "9       536366  22632          HAND WARMER RED POLKA DOT     6   \n",
       "...        ...    ...                                ...   ...   \n",
       "541905  581587  22613        PACK OF 20 SPACEBOY NAPKINS    12   \n",
       "541906  581587  22899       CHILDREN'S APRON DOLLY GIRL      6   \n",
       "541907  581587  23254      CHILDRENS CUTLERY DOLLY GIRL      4   \n",
       "541908  581587  23255    CHILDRENS CUTLERY CIRCUS PARADE     4   \n",
       "541909  581587  22138      BAKING SET 9 PIECE RETROSPOT      3   \n",
       "\n",
       "                   订单日期和时间 单价（英镑）     客户编号           国家的名称  \n",
       "2      2010-12-01 08:26:00   3.39  17850.0  United Kingdom  \n",
       "6      2010-12-01 08:26:00   7.65  17850.0  United Kingdom  \n",
       "7      2010-12-01 08:26:00   4.25  17850.0  United Kingdom  \n",
       "8      2010-12-01 08:28:00   1.85  17850.0  United Kingdom  \n",
       "9      2010-12-01 08:28:00   1.85  17850.0  United Kingdom  \n",
       "...                    ...    ...      ...             ...  \n",
       "541905 2011-12-09 12:50:00   0.85  12680.0          France  \n",
       "541906 2011-12-09 12:50:00    2.1  12680.0          France  \n",
       "541907 2011-12-09 12:50:00   4.15  12680.0          France  \n",
       "541908 2011-12-09 12:50:00   4.15  12680.0          France  \n",
       "541909 2011-12-09 12:50:00   4.95  12680.0          France  \n",
       "\n",
       "[371020 rows x 8 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data=film_date\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 1.购买商品数前十的国家是？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['United Kingdom',\n",
       " 'Netherlands',\n",
       " 'EIRE',\n",
       " 'Germany',\n",
       " 'France',\n",
       " 'Australia',\n",
       " 'Sweden',\n",
       " 'Switzerland',\n",
       " 'Japan',\n",
       " 'Spain']"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#通过国家和产品数量来统计得出排名前十的国家\n",
    "\n",
    "list=data.groupby(\"国家的名称\",as_index=False)[\"产品数量\"].sum()\n",
    "list.sort_values(by=\"产品数量\",ascending=False,inplace=True)\n",
    "list=list.head(10).reset_index().drop(\"index\",axis=1)\n",
    "type(list)\n",
    "np.array(list[\"国家的名称\"]).tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"cf605905ecd944e5b19d9b31cec69ad4\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_cf605905ecd944e5b19d9b31cec69ad4 = echarts.init(\n",
       "                    document.getElementById('cf605905ecd944e5b19d9b31cec69ad4'), 'white', {renderer: 'canvas'});\n",
       "                var option_cf605905ecd944e5b19d9b31cec69ad4 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"funnel\",\n",
       "            \"name\": \"\\u5546\\u54c1\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"United Kingdom\",\n",
       "                    \"value\": 3661496\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Netherlands\",\n",
       "                    \"value\": 193063\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"EIRE\",\n",
       "                    \"value\": 127576\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Germany\",\n",
       "                    \"value\": 109899\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"France\",\n",
       "                    \"value\": 104899\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Australia\",\n",
       "                    \"value\": 81541\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Sweden\",\n",
       "                    \"value\": 35113\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Switzerland\",\n",
       "                    \"value\": 27554\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Japan\",\n",
       "                    \"value\": 24561\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Spain\",\n",
       "                    \"value\": 22548\n",
       "                }\n",
       "            ],\n",
       "            \"sort\": \"ascending\",\n",
       "            \"gap\": 0,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"EIRE\",\n",
       "                \"France\",\n",
       "                \"Spain\",\n",
       "                \"Japan\",\n",
       "                \"Sweden\",\n",
       "                \"Australia\",\n",
       "                \"United Kingdom\",\n",
       "                \"Switzerland\",\n",
       "                \"Netherlands\",\n",
       "                \"Germany\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"United Kingdom\": true,\n",
       "                \"Netherlands\": true,\n",
       "                \"EIRE\": true,\n",
       "                \"Germany\": true,\n",
       "                \"France\": true,\n",
       "                \"Australia\": true,\n",
       "                \"Sweden\": true,\n",
       "                \"Switzerland\": true,\n",
       "                \"Japan\": true,\n",
       "                \"Spain\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"left\": \"2%\",\n",
       "            \"top\": \"15%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5168\\u5e74\\u5546\\u54c1\\u524d\\u5341\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_cf605905ecd944e5b19d9b31cec69ad4.setOption(option_cf605905ecd944e5b19d9b31cec69ad4);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1335b790>"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#漏斗图\n",
    "funnel=Funnel().add(\n",
    "        \"商品\",\n",
    "        list.values.tolist(),\n",
    "    sort_=\"ascending\",\n",
    "    ).set_global_opts(title_opts=opts.TitleOpts(title=\"全年商品前十\"),legend_opts=opts.LegendOpts(\n",
    "                orient=\"vertical\", pos_top=\"15%\", pos_left=\"2%\"\n",
    "            ))\n",
    "funnel.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'essos':'https://assets.pyecharts.org/assets/themes/essos'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"38cf06cf94ee4f8cb56bc7017b549130\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'essos'], function(echarts) {\n",
       "                var chart_38cf06cf94ee4f8cb56bc7017b549130 = echarts.init(\n",
       "                    document.getElementById('38cf06cf94ee4f8cb56bc7017b549130'), 'essos', {renderer: 'canvas'});\n",
       "                var option_38cf06cf94ee4f8cb56bc7017b549130 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\",\n",
       "            \"data\": [\n",
       "                3661496,\n",
       "                193063,\n",
       "                127576,\n",
       "                109899,\n",
       "                104899,\n",
       "                81541,\n",
       "                35113,\n",
       "                27554,\n",
       "                24561,\n",
       "                22548\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\",\n",
       "                        \"symbolSize\": [\n",
       "                            90,\n",
       "                            70\n",
       "                        ]\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5c0f\\u503c\",\n",
       "                        \"type\": \"min\",\n",
       "                        \"symbolSize\": [\n",
       "                            90,\n",
       "                            70\n",
       "                        ]\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u5e73\\u5747\\u503c\",\n",
       "                        \"type\": \"average\",\n",
       "                        \"symbolSize\": [\n",
       "                            90,\n",
       "                            70\n",
       "                        ]\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"name\": \"\\u56fd\\u5bb6\\u7684\\u540d\\u79f0\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"United Kingdom\",\n",
       "                \"Netherlands\",\n",
       "                \"EIRE\",\n",
       "                \"Germany\",\n",
       "                \"France\",\n",
       "                \"Australia\",\n",
       "                \"Sweden\",\n",
       "                \"Switzerland\",\n",
       "                \"Japan\",\n",
       "                \"Spain\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"name\": \"\\u4ea7\\u54c1\\u6570\\u91cf\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"itemSize\": 15,\n",
       "        \"itemGap\": 10,\n",
       "        \"left\": \"80%\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"type\": \"png\",\n",
       "                \"backgroundColor\": \"auto\",\n",
       "                \"connectedBackgroundColor\": \"#fff\",\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4fdd\\u5b58\\u4e3a\\u56fe\\u7247\",\n",
       "                \"pixelRatio\": 1\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u8fd8\\u539f\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u6570\\u636e\\u89c6\\u56fe\",\n",
       "                \"readOnly\": false,\n",
       "                \"lang\": [\n",
       "                    \"\\u6570\\u636e\\u89c6\\u56fe\",\n",
       "                    \"\\u5173\\u95ed\",\n",
       "                    \"\\u5237\\u65b0\"\n",
       "                ],\n",
       "                \"backgroundColor\": \"#fff\",\n",
       "                \"textareaColor\": \"#fff\",\n",
       "                \"textareaBorderColor\": \"#333\",\n",
       "                \"textColor\": \"#000\",\n",
       "                \"buttonColor\": \"#c23531\",\n",
       "                \"buttonTextColor\": \"#fff\"\n",
       "            },\n",
       "            \"dataZoom\": {\n",
       "                \"show\": true,\n",
       "                \"title\": {\n",
       "                    \"zoom\": \"\\u533a\\u57df\\u7f29\\u653e\",\n",
       "                    \"back\": \"\\u533a\\u57df\\u7f29\\u653e\\u8fd8\\u539f\"\n",
       "                },\n",
       "                \"icon\": {}\n",
       "            },\n",
       "            \"magicType\": {\n",
       "                \"show\": true,\n",
       "                \"type\": [\n",
       "                    \"line\",\n",
       "                    \"bar\",\n",
       "                    \"stack\",\n",
       "                    \"tiled\"\n",
       "                ],\n",
       "                \"title\": {\n",
       "                    \"line\": \"\\u5207\\u6362\\u4e3a\\u6298\\u7ebf\\u56fe\",\n",
       "                    \"bar\": \"\\u5207\\u6362\\u4e3a\\u67f1\\u72b6\\u56fe\",\n",
       "                    \"stack\": \"\\u5207\\u6362\\u4e3a\\u5806\\u53e0\",\n",
       "                    \"tiled\": \"\\u5207\\u6362\\u4e3a\\u5e73\\u94fa\"\n",
       "                },\n",
       "                \"icon\": {}\n",
       "            },\n",
       "            \"brush\": {\n",
       "                \"icon\": {},\n",
       "                \"title\": {\n",
       "                    \"rect\": \"\\u77e9\\u5f62\\u9009\\u62e9\",\n",
       "                    \"polygon\": \"\\u5708\\u9009\",\n",
       "                    \"lineX\": \"\\u6a2a\\u5411\\u9009\\u62e9\",\n",
       "                    \"lineY\": \"\\u7eb5\\u5411\\u9009\\u62e9\",\n",
       "                    \"keep\": \"\\u4fdd\\u6301\\u9009\\u62e9\",\n",
       "                    \"clear\": \"\\u6e05\\u9664\\u9009\\u62e9\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false\n",
       "    }\n",
       "};\n",
       "                chart_38cf06cf94ee4f8cb56bc7017b549130.setOption(option_38cf06cf94ee4f8cb56bc7017b549130);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x138aa450>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(init_opts=opts.InitOpts(theme=ThemeType.ESSOS))\n",
    "bar.add_xaxis(np.array(list[\"国家的名称\"]).tolist())\n",
    "bar.add_yaxis(\"排名前十的国家\",np.array(list[\"产品数量\"]).tolist())\n",
    "#设置全局配置\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title=\"排名前十的国家\"),\n",
    "                    toolbox_opts=opts.ToolboxOpts(),\n",
    "                    datazoom_opts=opts.DataZoomOpts(is_show=True),\n",
    "                   yaxis_opts=opts.AxisOpts(\n",
    "                    name='产品数量'),\n",
    "                    xaxis_opts=opts.AxisOpts(\n",
    "                    name='国家的名称')\n",
    "                   )\n",
    "#设置系列配置label_opts=opts.LabelOpts(font_size=20,font_style=\"italic\"),\n",
    "bar.set_series_opts(\n",
    "                    label_opts=opts.LabelOpts(is_show=False),\n",
    "                    markpoint_opts=opts.MarkPointOpts(\n",
    "                data=[\n",
    "                    opts.MarkPointItem(type_=\"max\", name=\"最大值\",symbol_size=[90, 70]),\n",
    "                    opts.MarkPointItem(type_=\"min\", name=\"最小值\",symbol_size=[90, 70]),\n",
    "                    opts.MarkPointItem(type_=\"average\", name=\"平均值\",symbol_size=[90, 70]),\n",
    "                    \n",
    "                ]\n",
    "            ))\n",
    "\n",
    "bar.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'essos':'https://assets.pyecharts.org/assets/themes/essos'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"1f66229143fc4138909b8b00aea81170\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'essos'], function(echarts) {\n",
       "                var chart_1f66229143fc4138909b8b00aea81170 = echarts.init(\n",
       "                    document.getElementById('1f66229143fc4138909b8b00aea81170'), 'essos', {renderer: 'canvas'});\n",
       "                var option_1f66229143fc4138909b8b00aea81170 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"United Kingdom\",\n",
       "                    \"value\": 3661496\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Netherlands\",\n",
       "                    \"value\": 193063\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"EIRE\",\n",
       "                    \"value\": 127576\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Germany\",\n",
       "                    \"value\": 109899\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"France\",\n",
       "                    \"value\": 104899\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Australia\",\n",
       "                    \"value\": 81541\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Sweden\",\n",
       "                    \"value\": 35113\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Switzerland\",\n",
       "                    \"value\": 27554\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Japan\",\n",
       "                    \"value\": 24561\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"Spain\",\n",
       "                    \"value\": 22548\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"United Kingdom\",\n",
       "                \"Netherlands\",\n",
       "                \"EIRE\",\n",
       "                \"Germany\",\n",
       "                \"France\",\n",
       "                \"Australia\",\n",
       "                \"Sweden\",\n",
       "                \"Switzerland\",\n",
       "                \"Japan\",\n",
       "                \"Spain\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"left\": \"2%\",\n",
       "            \"top\": \"15%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u9500\\u552e\\u989d\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_1f66229143fc4138909b8b00aea81170.setOption(option_1f66229143fc4138909b8b00aea81170);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x138aa4f0>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#饼图 \n",
    "pie=Pie(init_opts=opts.InitOpts(theme=ThemeType.ESSOS)).add(\"\",list.values.tolist())\n",
    "pie.set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
    "pie.set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"销售额排名前十的国家\"),\n",
    "            legend_opts=opts.LegendOpts(\n",
    "                orient=\"vertical\", pos_top=\"15%\", pos_left=\"2%\"\n",
    "            ),\n",
    "        )\n",
    "pie.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 2. 交易额前十的国家是？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\program files\\python\\lib\\site-packages\\pandas\\core\\indexing.py:1743: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  isetter(ilocs[0], value)\n",
      "d:\\program files\\python\\lib\\site-packages\\pandas\\core\\indexing.py:1596: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  self.obj[key] = _infer_fill_value(value)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>国家的名称</th>\n",
       "      <th>销售额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>United Kingdom</td>\n",
       "      <td>6.202993e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Netherlands</td>\n",
       "      <td>2.689354e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>EIRE</td>\n",
       "      <td>2.333032e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Germany</td>\n",
       "      <td>1.855734e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>France</td>\n",
       "      <td>1.711794e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Australia</td>\n",
       "      <td>1.328914e+05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Switzerland</td>\n",
       "      <td>4.754403e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Spain</td>\n",
       "      <td>3.987988e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Sweden</td>\n",
       "      <td>3.465363e+04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Belgium</td>\n",
       "      <td>3.459105e+04</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            国家的名称           销售额\n",
       "0  United Kingdom  6.202993e+06\n",
       "1     Netherlands  2.689354e+05\n",
       "2            EIRE  2.333032e+05\n",
       "3         Germany  1.855734e+05\n",
       "4          France  1.711794e+05\n",
       "5       Australia  1.328914e+05\n",
       "6     Switzerland  4.754403e+04\n",
       "7           Spain  3.987988e+04\n",
       "8          Sweden  3.465363e+04\n",
       "9         Belgium  3.459105e+04"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#通过产品数量和单价计算出销售额，排序之后得出排名前十的国家\n",
    "film_date.loc[:,\"单价（英镑）\"]=film_date[\"单价（英镑）\"].astype(np.float64)\n",
    "film_date.loc[:,\"销售额\"]=film_date[\"产品数量\"]*film_date[\"单价（英镑）\"]\n",
    "list_sales=film_date.groupby(film_date[\"国家的名称\"],as_index=False)[\"销售额\"].sum()\n",
    "list_sales=list_sales.sort_values(by=\"销售额\",ascending=False)\n",
    "list_sales=list_sales.head(10).reset_index().drop(\"index\",axis=1)\n",
    "list_sales"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'essos':'https://assets.pyecharts.org/assets/themes/essos'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"d4d21ccb85624f5b80bfc7dc04ac8ad0\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'essos'], function(echarts) {\n",
       "                var chart_d4d21ccb85624f5b80bfc7dc04ac8ad0 = echarts.init(\n",
       "                    document.getElementById('d4d21ccb85624f5b80bfc7dc04ac8ad0'), 'essos', {renderer: 'canvas'});\n",
       "                var option_d4d21ccb85624f5b80bfc7dc04ac8ad0 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u9500\\u552e\\u989d\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\",\n",
       "            \"data\": [\n",
       "                6202993.28,\n",
       "                268935.38,\n",
       "                233303.19,\n",
       "                185573.36,\n",
       "                171179.37,\n",
       "                132891.39,\n",
       "                47544.03,\n",
       "                39879.88,\n",
       "                34653.63,\n",
       "                34591.05\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"fontSize\": 20,\n",
       "                \"fontStyle\": \"italic\"\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5c0f\\u503c\",\n",
       "                        \"type\": \"min\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u5e73\\u5747\\u503c\",\n",
       "                        \"type\": \"average\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u9500\\u552e\\u989d\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u9500\\u552e\\u989d\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"name\": \"\\u56fd\\u5bb6\\u7684\\u540d\\u79f0\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"United Kingdom\",\n",
       "                \"Netherlands\",\n",
       "                \"EIRE\",\n",
       "                \"Germany\",\n",
       "                \"France\",\n",
       "                \"Australia\",\n",
       "                \"Switzerland\",\n",
       "                \"Spain\",\n",
       "                \"Sweden\",\n",
       "                \"Belgium\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"name\": \"\\u9500\\u552e\\u989d(\\u82f1\\u9551)\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4ea4\\u6613\\u989d\\u6392\\u540d\\u524d\\u5341\\u7684\\u56fd\\u5bb6\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"itemSize\": 15,\n",
       "        \"itemGap\": 10,\n",
       "        \"left\": \"80%\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"type\": \"png\",\n",
       "                \"backgroundColor\": \"auto\",\n",
       "                \"connectedBackgroundColor\": \"#fff\",\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4fdd\\u5b58\\u4e3a\\u56fe\\u7247\",\n",
       "                \"pixelRatio\": 1\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u8fd8\\u539f\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u6570\\u636e\\u89c6\\u56fe\",\n",
       "                \"readOnly\": false,\n",
       "                \"lang\": [\n",
       "                    \"\\u6570\\u636e\\u89c6\\u56fe\",\n",
       "                    \"\\u5173\\u95ed\",\n",
       "                    \"\\u5237\\u65b0\"\n",
       "                ],\n",
       "                \"backgroundColor\": \"#fff\",\n",
       "                \"textareaColor\": \"#fff\",\n",
       "                \"textareaBorderColor\": \"#333\",\n",
       "                \"textColor\": \"#000\",\n",
       "                \"buttonColor\": \"#c23531\",\n",
       "                \"buttonTextColor\": \"#fff\"\n",
       "            },\n",
       "            \"dataZoom\": {\n",
       "                \"show\": true,\n",
       "                \"title\": {\n",
       "                    \"zoom\": \"\\u533a\\u57df\\u7f29\\u653e\",\n",
       "                    \"back\": \"\\u533a\\u57df\\u7f29\\u653e\\u8fd8\\u539f\"\n",
       "                },\n",
       "                \"icon\": {}\n",
       "            },\n",
       "            \"magicType\": {\n",
       "                \"show\": true,\n",
       "                \"type\": [\n",
       "                    \"line\",\n",
       "                    \"bar\",\n",
       "                    \"stack\",\n",
       "                    \"tiled\"\n",
       "                ],\n",
       "                \"title\": {\n",
       "                    \"line\": \"\\u5207\\u6362\\u4e3a\\u6298\\u7ebf\\u56fe\",\n",
       "                    \"bar\": \"\\u5207\\u6362\\u4e3a\\u67f1\\u72b6\\u56fe\",\n",
       "                    \"stack\": \"\\u5207\\u6362\\u4e3a\\u5806\\u53e0\",\n",
       "                    \"tiled\": \"\\u5207\\u6362\\u4e3a\\u5e73\\u94fa\"\n",
       "                },\n",
       "                \"icon\": {}\n",
       "            },\n",
       "            \"brush\": {\n",
       "                \"icon\": {},\n",
       "                \"title\": {\n",
       "                    \"rect\": \"\\u77e9\\u5f62\\u9009\\u62e9\",\n",
       "                    \"polygon\": \"\\u5708\\u9009\",\n",
       "                    \"lineX\": \"\\u6a2a\\u5411\\u9009\\u62e9\",\n",
       "                    \"lineY\": \"\\u7eb5\\u5411\\u9009\\u62e9\",\n",
       "                    \"keep\": \"\\u4fdd\\u6301\\u9009\\u62e9\",\n",
       "                    \"clear\": \"\\u6e05\\u9664\\u9009\\u62e9\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false\n",
       "    }\n",
       "};\n",
       "                chart_d4d21ccb85624f5b80bfc7dc04ac8ad0.setOption(option_d4d21ccb85624f5b80bfc7dc04ac8ad0);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x141c83b0>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#柱形图\n",
    "bar = Bar(init_opts=opts.InitOpts(theme=ThemeType.ESSOS))\n",
    "bar.add_xaxis(np.array(list_sales[\"国家的名称\"]).tolist())\n",
    "bar.add_yaxis(\"销售额排名前十的国家\",np.array(list_sales[\"销售额\"]).round(2).tolist())\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title=\"交易额排名前十的国家\"),\n",
    "                    toolbox_opts=opts.ToolboxOpts(),\n",
    "                    datazoom_opts=opts.DataZoomOpts(is_show=True),\n",
    "                   yaxis_opts=opts.AxisOpts(\n",
    "                    name='销售额(英镑)'),\n",
    "                    xaxis_opts=opts.AxisOpts(\n",
    "                    name='国家的名称')\n",
    "                   )\n",
    "bar.set_series_opts(label_opts=opts.LabelOpts(font_size=20,font_style=\"italic\"),\n",
    "            markline_opts=opts.MarkLineOpts(\n",
    "                data=[\n",
    "                    opts.MarkLineItem(type_=\"max\", name=\"最大值\"),\n",
    "                    opts.MarkLineItem(type_=\"min\", name=\"最小值\"),\n",
    "                    opts.MarkLineItem(type_=\"average\", name=\"平均值\"),\n",
    "                ]\n",
    "            ))\n",
    "bar.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 3.哪些月份销量较佳？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\program files\\python\\lib\\site-packages\\ipykernel_launcher.py:4: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  after removing the cwd from sys.path.\n",
      "d:\\program files\\python\\lib\\site-packages\\ipykernel_launcher.py:6: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \n",
      "d:\\program files\\python\\lib\\site-packages\\ipykernel_launcher.py:7: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  import sys\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单日期和时间</th>\n",
       "      <th>产品数量</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2011-11</td>\n",
       "      <td>620358</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2011-10</td>\n",
       "      <td>531816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2011-09</td>\n",
       "      <td>501976</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2011-08</td>\n",
       "      <td>355492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2011-05</td>\n",
       "      <td>338177</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2011-07</td>\n",
       "      <td>332333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2011-06</td>\n",
       "      <td>329235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2011-03</td>\n",
       "      <td>312207</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2010-12</td>\n",
       "      <td>266479</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2011-04</td>\n",
       "      <td>250371</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2011-02</td>\n",
       "      <td>240684</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2011-01</td>\n",
       "      <td>238707</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2011-12</td>\n",
       "      <td>191572</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    订单日期和时间    产品数量\n",
       "0   2011-11  620358\n",
       "1   2011-10  531816\n",
       "2   2011-09  501976\n",
       "3   2011-08  355492\n",
       "4   2011-05  338177\n",
       "5   2011-07  332333\n",
       "6   2011-06  329235\n",
       "7   2011-03  312207\n",
       "8   2010-12  266479\n",
       "9   2011-04  250371\n",
       "10  2011-02  240684\n",
       "11  2011-01  238707\n",
       "12  2011-12  191572"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#去掉日期的时分秒精度\n",
    "film=film_date\n",
    "\n",
    "film['订单日期和时间']=film['订单日期和时间'].dt.date\n",
    "#将日期转换成str，然后取出年月\n",
    "film['订单日期和时间']=film['订单日期和时间'].astype(np.str)\n",
    "film['订单日期和时间']=film['订单日期和时间'].str[:7]\n",
    "#进行求和，排序并重新建立索引\n",
    "list_month_sales=film.groupby(film[\"订单日期和时间\"],as_index=False)[\"产品数量\"].sum()\n",
    "list_month_sales=list_month_sales.sort_values(by=\"产品数量\",ascending=False)\n",
    "list_month_sales=list_month_sales.reset_index().drop(\"index\",axis=1)\n",
    "list_month_sales\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'essos':'https://assets.pyecharts.org/assets/themes/essos'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"07c5489284c748cbb4dd351fee479da8\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'essos'], function(echarts) {\n",
       "                var chart_07c5489284c748cbb4dd351fee479da8 = echarts.init(\n",
       "                    document.getElementById('07c5489284c748cbb4dd351fee479da8'), 'essos', {renderer: 'canvas'});\n",
       "                var option_07c5489284c748cbb4dd351fee479da8 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"2010\\u5e7412\\u6708\\u52302011\\u5e7412\\u6708\\u7684\\u4ea7\\u54c1\\u6570\\u91cf\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2011-11\",\n",
       "                    620358\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-10\",\n",
       "                    531816\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-09\",\n",
       "                    501976\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-08\",\n",
       "                    355492\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-05\",\n",
       "                    338177\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-07\",\n",
       "                    332333\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-06\",\n",
       "                    329235\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-03\",\n",
       "                    312207\n",
       "                ],\n",
       "                [\n",
       "                    \"2010-12\",\n",
       "                    266479\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-04\",\n",
       "                    250371\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-02\",\n",
       "                    240684\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-01\",\n",
       "                    238707\n",
       "                ],\n",
       "                [\n",
       "                    \"2011-12\",\n",
       "                    191572\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"fontSize\": 20,\n",
       "                \"fontStyle\": \"italic\"\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"silent\": false,\n",
       "                \"precision\": 2,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"top\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5927\\u503c\",\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u6700\\u5c0f\\u503c\",\n",
       "                        \"type\": \"min\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"name\": \"\\u5e73\\u5747\\u503c\",\n",
       "                        \"type\": \"average\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"2010\\u5e7412\\u6708\\u52302011\\u5e7412\\u6708\\u7684\\u4ea7\\u54c1\\u6570\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"2010\\u5e7412\\u6708\\u52302011\\u5e7412\\u6708\\u7684\\u4ea7\\u54c1\\u6570\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"name\": \"\\u8ba2\\u5355\\u65e5\\u671f\\u548c\\u65f6\\u95f4\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2011-11\",\n",
       "                \"2011-10\",\n",
       "                \"2011-09\",\n",
       "                \"2011-08\",\n",
       "                \"2011-05\",\n",
       "                \"2011-07\",\n",
       "                \"2011-06\",\n",
       "                \"2011-03\",\n",
       "                \"2010-12\",\n",
       "                \"2011-04\",\n",
       "                \"2011-02\",\n",
       "                \"2011-01\",\n",
       "                \"2011-12\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"name\": \"\\u4ea7\\u54c1\\u6570\\u91cf\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"2010\\u5e7412\\u6708\\u52302011\\u5e7412\\u6708\\u7684\\u4ea7\\u54c1\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"itemSize\": 15,\n",
       "        \"itemGap\": 10,\n",
       "        \"left\": \"80%\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"type\": \"png\",\n",
       "                \"backgroundColor\": \"auto\",\n",
       "                \"connectedBackgroundColor\": \"#fff\",\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4fdd\\u5b58\\u4e3a\\u56fe\\u7247\",\n",
       "                \"pixelRatio\": 1\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u8fd8\\u539f\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u6570\\u636e\\u89c6\\u56fe\",\n",
       "                \"readOnly\": false,\n",
       "                \"lang\": [\n",
       "                    \"\\u6570\\u636e\\u89c6\\u56fe\",\n",
       "                    \"\\u5173\\u95ed\",\n",
       "                    \"\\u5237\\u65b0\"\n",
       "                ],\n",
       "                \"backgroundColor\": \"#fff\",\n",
       "                \"textareaColor\": \"#fff\",\n",
       "                \"textareaBorderColor\": \"#333\",\n",
       "                \"textColor\": \"#000\",\n",
       "                \"buttonColor\": \"#c23531\",\n",
       "                \"buttonTextColor\": \"#fff\"\n",
       "            },\n",
       "            \"dataZoom\": {\n",
       "                \"show\": true,\n",
       "                \"title\": {\n",
       "                    \"zoom\": \"\\u533a\\u57df\\u7f29\\u653e\",\n",
       "                    \"back\": \"\\u533a\\u57df\\u7f29\\u653e\\u8fd8\\u539f\"\n",
       "                },\n",
       "                \"icon\": {}\n",
       "            },\n",
       "            \"magicType\": {\n",
       "                \"show\": true,\n",
       "                \"type\": [\n",
       "                    \"line\",\n",
       "                    \"bar\",\n",
       "                    \"stack\",\n",
       "                    \"tiled\"\n",
       "                ],\n",
       "                \"title\": {\n",
       "                    \"line\": \"\\u5207\\u6362\\u4e3a\\u6298\\u7ebf\\u56fe\",\n",
       "                    \"bar\": \"\\u5207\\u6362\\u4e3a\\u67f1\\u72b6\\u56fe\",\n",
       "                    \"stack\": \"\\u5207\\u6362\\u4e3a\\u5806\\u53e0\",\n",
       "                    \"tiled\": \"\\u5207\\u6362\\u4e3a\\u5e73\\u94fa\"\n",
       "                },\n",
       "                \"icon\": {}\n",
       "            },\n",
       "            \"brush\": {\n",
       "                \"icon\": {},\n",
       "                \"title\": {\n",
       "                    \"rect\": \"\\u77e9\\u5f62\\u9009\\u62e9\",\n",
       "                    \"polygon\": \"\\u5708\\u9009\",\n",
       "                    \"lineX\": \"\\u6a2a\\u5411\\u9009\\u62e9\",\n",
       "                    \"lineY\": \"\\u7eb5\\u5411\\u9009\\u62e9\",\n",
       "                    \"keep\": \"\\u4fdd\\u6301\\u9009\\u62e9\",\n",
       "                    \"clear\": \"\\u6e05\\u9664\\u9009\\u62e9\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false\n",
       "    }\n",
       "};\n",
       "                chart_07c5489284c748cbb4dd351fee479da8.setOption(option_07c5489284c748cbb4dd351fee479da8);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x4a14df0>"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#条形图\n",
    "line = Line(init_opts=opts.InitOpts(theme=ThemeType.ESSOS))\n",
    "line.add_xaxis(np.array(list_month_sales[\"订单日期和时间\"]).tolist())\n",
    "line.add_yaxis(\"2010年12月到2011年12月的产品数量\",np.array(list_month_sales[\"产品数量\"]).round(2).tolist())\n",
    "line.set_global_opts(title_opts=opts.TitleOpts(title=\"2010年12月到2011年12月的产品数量\"),\n",
    "                    toolbox_opts=opts.ToolboxOpts(),\n",
    "                    datazoom_opts=opts.DataZoomOpts(is_show=True),\n",
    "                   yaxis_opts=opts.AxisOpts(\n",
    "                    name='产品数量'),\n",
    "                    xaxis_opts=opts.AxisOpts(\n",
    "                    name='订单日期和时间')\n",
    "                   )\n",
    "line.set_series_opts(label_opts=opts.LabelOpts(font_size=20,font_style=\"italic\"),\n",
    "            markline_opts=opts.MarkLineOpts(\n",
    "                data=[\n",
    "                    opts.MarkLineItem(type_=\"max\", name=\"最大值\"),\n",
    "                    opts.MarkLineItem(type_=\"min\", name=\"最小值\"),\n",
    "                    opts.MarkLineItem(type_=\"average\", name=\"平均值\"),\n",
    "                ]\n",
    "            ))\n",
    "line.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'essos':'https://assets.pyecharts.org/assets/themes/essos'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"460f089e36ca42bc9ee108a2a187dbc1\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'essos'], function(echarts) {\n",
       "                var chart_460f089e36ca42bc9ee108a2a187dbc1 = echarts.init(\n",
       "                    document.getElementById('460f089e36ca42bc9ee108a2a187dbc1'), 'essos', {renderer: 'canvas'});\n",
       "                var option_460f089e36ca42bc9ee108a2a187dbc1 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"2011-11\",\n",
       "                    \"value\": 620358\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-10\",\n",
       "                    \"value\": 531816\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-09\",\n",
       "                    \"value\": 501976\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-08\",\n",
       "                    \"value\": 355492\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-05\",\n",
       "                    \"value\": 338177\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-07\",\n",
       "                    \"value\": 332333\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-06\",\n",
       "                    \"value\": 329235\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-03\",\n",
       "                    \"value\": 312207\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2010-12\",\n",
       "                    \"value\": 266479\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-04\",\n",
       "                    \"value\": 250371\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-02\",\n",
       "                    \"value\": 240684\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-01\",\n",
       "                    \"value\": 238707\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-12\",\n",
       "                    \"value\": 191572\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"2011-11\",\n",
       "                \"2011-10\",\n",
       "                \"2011-09\",\n",
       "                \"2011-08\",\n",
       "                \"2011-05\",\n",
       "                \"2011-07\",\n",
       "                \"2011-06\",\n",
       "                \"2011-03\",\n",
       "                \"2010-12\",\n",
       "                \"2011-04\",\n",
       "                \"2011-02\",\n",
       "                \"2011-01\",\n",
       "                \"2011-12\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"left\": \"2%\",\n",
       "            \"top\": \"15%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"2010\\u5e7412\\u6708\\u52302011\\u5e7412\\u6708\\u7684\\u4ea7\\u54c1\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_460f089e36ca42bc9ee108a2a187dbc1.setOption(option_460f089e36ca42bc9ee108a2a187dbc1);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x141c91d0>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#饼图 \n",
    "pie=Pie(init_opts=opts.InitOpts(theme=ThemeType.ESSOS)).add(\"\",list_month_sales.values.tolist())\n",
    "pie.set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
    "pie.set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"2010年12月到2011年12月的产品数量\"),\n",
    "            legend_opts=opts.LegendOpts(\n",
    "                orient=\"vertical\", pos_top=\"15%\", pos_left=\"2%\"\n",
    "            ),\n",
    "        )\n",
    "pie.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"77a725ff39664c26b087fe493196a0df\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_77a725ff39664c26b087fe493196a0df = echarts.init(\n",
       "                    document.getElementById('77a725ff39664c26b087fe493196a0df'), 'white', {renderer: 'canvas'});\n",
       "                var option_77a725ff39664c26b087fe493196a0df = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"2011-11\",\n",
       "                    \"value\": 620358\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-10\",\n",
       "                    \"value\": 531816\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-09\",\n",
       "                    \"value\": 501976\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-08\",\n",
       "                    \"value\": 355492\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-05\",\n",
       "                    \"value\": 338177\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-07\",\n",
       "                    \"value\": 332333\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-06\",\n",
       "                    \"value\": 329235\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-03\",\n",
       "                    \"value\": 312207\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2010-12\",\n",
       "                    \"value\": 266479\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-04\",\n",
       "                    \"value\": 250371\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-02\",\n",
       "                    \"value\": 240684\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-01\",\n",
       "                    \"value\": 238707\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2011-12\",\n",
       "                    \"value\": 191572\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"30%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"60%\"\n",
       "            ],\n",
       "            \"roseType\": \"area\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"2011-11\",\n",
       "                \"2011-10\",\n",
       "                \"2011-09\",\n",
       "                \"2011-08\",\n",
       "                \"2011-05\",\n",
       "                \"2011-07\",\n",
       "                \"2011-06\",\n",
       "                \"2011-03\",\n",
       "                \"2010-12\",\n",
       "                \"2011-04\",\n",
       "                \"2011-02\",\n",
       "                \"2011-01\",\n",
       "                \"2011-12\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"left\": \"2%\",\n",
       "            \"top\": \"15%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"2010\\u5e7412\\u6708\\u52302011\\u5e7412\\u6708\\u7684\\u4ea7\\u54c1\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_77a725ff39664c26b087fe493196a0df.setOption(option_77a725ff39664c26b087fe493196a0df);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x59e83b0>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pie=Pie().add(\n",
    "            \"\",\n",
    "            list_month_sales.values.tolist(),\n",
    "            radius=[\"30%\", \"75%\"],\n",
    "            center=[\"50%\", \"60%\"],\n",
    "            rosetype=\"area\"\n",
    "        ).set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"2010年12月到2011年12月的产品数量\"),\n",
    "            legend_opts=opts.LegendOpts(\n",
    "                orient=\"vertical\", pos_top=\"15%\", pos_left=\"2%\"\n",
    "            )\n",
    "        )\n",
    "pie.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 4.客单价多少？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\program files\\python\\lib\\site-packages\\ipykernel_launcher.py:3: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  This is separate from the ipykernel package so we can avoid doing imports until\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "20.4"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#用销售总额除以顾客数得出客单价\n",
    "price=film_date[\"销售额\"].sum()\n",
    "film_date[\"客户编号\"]=film_date[\"客户编号\"].drop_duplicates().reset_index().drop('index',axis=1)\n",
    "user=len(film_date[\"客户编号\"])\n",
    "user_price=(price/user).round(2)\n",
    "user_price"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 5.用户消费行为分析\n",
    "   - 圣诞节前后的购物习惯\n",
    "   - 退货最多的月份\n",
    "   - 退货最多的国家"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单编号</th>\n",
       "      <th>产品编号</th>\n",
       "      <th>产品描述</th>\n",
       "      <th>产品数量</th>\n",
       "      <th>订单日期和时间</th>\n",
       "      <th>单价（英镑）</th>\n",
       "      <th>客户编号</th>\n",
       "      <th>国家的名称</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>29016</th>\n",
       "      <td>C538684</td>\n",
       "      <td>21258</td>\n",
       "      <td>VICTORIAN SEWING BOX LARGE</td>\n",
       "      <td>-1</td>\n",
       "      <td>2010-12-14 09:26:00</td>\n",
       "      <td>12.75</td>\n",
       "      <td>16161.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29017</th>\n",
       "      <td>C538684</td>\n",
       "      <td>22946</td>\n",
       "      <td>WOODEN ADVENT CALENDAR CREAM</td>\n",
       "      <td>-1</td>\n",
       "      <td>2010-12-14 09:26:00</td>\n",
       "      <td>16.95</td>\n",
       "      <td>16161.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29018</th>\n",
       "      <td>C538684</td>\n",
       "      <td>22470</td>\n",
       "      <td>HEART OF WICKER LARGE</td>\n",
       "      <td>-1</td>\n",
       "      <td>2010-12-14 09:26:00</td>\n",
       "      <td>2.95</td>\n",
       "      <td>16161.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29021</th>\n",
       "      <td>538687</td>\n",
       "      <td>22961</td>\n",
       "      <td>JAM MAKING SET PRINTED</td>\n",
       "      <td>96</td>\n",
       "      <td>2010-12-14 09:50:00</td>\n",
       "      <td>1.25</td>\n",
       "      <td>13324.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29022</th>\n",
       "      <td>538687</td>\n",
       "      <td>22666</td>\n",
       "      <td>RECIPE BOX PANTRY YELLOW DESIGN</td>\n",
       "      <td>24</td>\n",
       "      <td>2010-12-14 09:50:00</td>\n",
       "      <td>2.55</td>\n",
       "      <td>13324.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42446</th>\n",
       "      <td>539988</td>\n",
       "      <td>22197</td>\n",
       "      <td>SMALL POPCORN HOLDER</td>\n",
       "      <td>2</td>\n",
       "      <td>2010-12-23 16:06:00</td>\n",
       "      <td>0.85</td>\n",
       "      <td>18116.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42447</th>\n",
       "      <td>539988</td>\n",
       "      <td>22834</td>\n",
       "      <td>HAND WARMER BABUSHKA DESIGN</td>\n",
       "      <td>4</td>\n",
       "      <td>2010-12-23 16:06:00</td>\n",
       "      <td>2.1</td>\n",
       "      <td>18116.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42448</th>\n",
       "      <td>539988</td>\n",
       "      <td>84378</td>\n",
       "      <td>SET OF 3 HEART COOKIE CUTTERS</td>\n",
       "      <td>1</td>\n",
       "      <td>2010-12-23 16:06:00</td>\n",
       "      <td>1.25</td>\n",
       "      <td>18116.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42449</th>\n",
       "      <td>539988</td>\n",
       "      <td>84380</td>\n",
       "      <td>SET OF 3 BUTTERFLY COOKIE CUTTERS</td>\n",
       "      <td>1</td>\n",
       "      <td>2010-12-23 16:06:00</td>\n",
       "      <td>1.25</td>\n",
       "      <td>18116.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42452</th>\n",
       "      <td>539988</td>\n",
       "      <td>22854</td>\n",
       "      <td>CREAM SWEETHEART EGG HOLDER</td>\n",
       "      <td>2</td>\n",
       "      <td>2010-12-23 16:06:00</td>\n",
       "      <td>4.95</td>\n",
       "      <td>18116.0</td>\n",
       "      <td>United Kingdom</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>6866 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          订单编号   产品编号                               产品描述  产品数量  \\\n",
       "29016  C538684  21258         VICTORIAN SEWING BOX LARGE    -1   \n",
       "29017  C538684  22946       WOODEN ADVENT CALENDAR CREAM    -1   \n",
       "29018  C538684  22470              HEART OF WICKER LARGE    -1   \n",
       "29021   538687  22961             JAM MAKING SET PRINTED    96   \n",
       "29022   538687  22666    RECIPE BOX PANTRY YELLOW DESIGN    24   \n",
       "...        ...    ...                                ...   ...   \n",
       "42446   539988  22197               SMALL POPCORN HOLDER     2   \n",
       "42447   539988  22834        HAND WARMER BABUSHKA DESIGN     4   \n",
       "42448   539988  84378      SET OF 3 HEART COOKIE CUTTERS     1   \n",
       "42449   539988  84380  SET OF 3 BUTTERFLY COOKIE CUTTERS     1   \n",
       "42452   539988  22854        CREAM SWEETHEART EGG HOLDER     2   \n",
       "\n",
       "                  订单日期和时间 单价（英镑）     客户编号           国家的名称  \n",
       "29016 2010-12-14 09:26:00  12.75  16161.0  United Kingdom  \n",
       "29017 2010-12-14 09:26:00  16.95  16161.0  United Kingdom  \n",
       "29018 2010-12-14 09:26:00   2.95  16161.0  United Kingdom  \n",
       "29021 2010-12-14 09:50:00   1.25  13324.0  United Kingdom  \n",
       "29022 2010-12-14 09:50:00   2.55  13324.0  United Kingdom  \n",
       "...                   ...    ...      ...             ...  \n",
       "42446 2010-12-23 16:06:00   0.85  18116.0  United Kingdom  \n",
       "42447 2010-12-23 16:06:00    2.1  18116.0  United Kingdom  \n",
       "42448 2010-12-23 16:06:00   1.25  18116.0  United Kingdom  \n",
       "42449 2010-12-23 16:06:00   1.25  18116.0  United Kingdom  \n",
       "42452 2010-12-23 16:06:00   4.95  18116.0  United Kingdom  \n",
       "\n",
       "[6866 rows x 8 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 圣诞节前后的购物习惯\n",
    "#2010年12月14到2010年12月31的购买数据（商品销售最多）\n",
    "film_date\n",
    "shop_Christmas=film_date[film_date['订单日期和时间']>='2010-12-14']\n",
    "shop_Christmas=shop_Christmas[shop_Christmas['订单日期和时间']<='2010-12-31']\n",
    "# shop_Christmas.to_csv(\"111.csv\",encoding=\"gbk\")\n",
    "shop_Christmas\n",
    "# film_date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>产品描述</th>\n",
       "      <th>产品数量</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>GROW A FLYTRAP OR SUNFLOWER IN TIN</td>\n",
       "      <td>2592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>HAND WARMER BABUSHKA DESIGN</td>\n",
       "      <td>2047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>PACK OF 72 RETROSPOT CAKE CASES</td>\n",
       "      <td>1856</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>PACK OF 12 LONDON TISSUES</td>\n",
       "      <td>1617</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>72 SWEETHEART FAIRY CAKE CASES</td>\n",
       "      <td>1114</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>SMALL POPCORN HOLDER</td>\n",
       "      <td>1030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>PACK OF 60 PINK PAISLEY CAKE CASES</td>\n",
       "      <td>1015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>WORLD WAR 2 GLIDERS ASSTD DESIGNS</td>\n",
       "      <td>1011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>60 TEATIME FAIRY CAKE CASES</td>\n",
       "      <td>983</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>RED TOADSTOOL LED NIGHT LIGHT</td>\n",
       "      <td>956</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                 产品描述  产品数量\n",
       "0  GROW A FLYTRAP OR SUNFLOWER IN TIN  2592\n",
       "1         HAND WARMER BABUSHKA DESIGN  2047\n",
       "2     PACK OF 72 RETROSPOT CAKE CASES  1856\n",
       "3          PACK OF 12 LONDON TISSUES   1617\n",
       "4      72 SWEETHEART FAIRY CAKE CASES  1114\n",
       "5                SMALL POPCORN HOLDER  1030\n",
       "6  PACK OF 60 PINK PAISLEY CAKE CASES  1015\n",
       "7   WORLD WAR 2 GLIDERS ASSTD DESIGNS  1011\n",
       "8         60 TEATIME FAIRY CAKE CASES   983\n",
       "9       RED TOADSTOOL LED NIGHT LIGHT   956"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#圣诞节商品前十\n",
    "shop_Christmas_sales=shop_Christmas.groupby(shop_Christmas[\"产品描述\"],as_index=False)[\"产品数量\"].sum()\n",
    "shop_Christmas_sales=shop_Christmas_sales.sort_values(by=\"产品数量\",ascending=False)\n",
    "shop_Christmas_sales=shop_Christmas_sales.reset_index().drop(\"index\",axis=1).head(10)\n",
    "#全年商品前十\n",
    "shop_sales=film_date\n",
    "shop_sales=shop_sales.groupby(shop_sales[\"产品描述\"],as_index=False)[\"产品数量\"].sum()\n",
    "shop_sales=shop_sales.sort_values(by=\"产品数量\",ascending=False)\n",
    "shop_sales=shop_sales.reset_index().drop(\"index\",axis=1).head(10)\n",
    "shop_sales\n",
    "shop_Christmas_sales"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"5de5bf824d284159970bbe02006c1ac3\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_5de5bf824d284159970bbe02006c1ac3 = echarts.init(\n",
       "                    document.getElementById('5de5bf824d284159970bbe02006c1ac3'), 'white', {renderer: 'canvas'});\n",
       "                var option_5de5bf824d284159970bbe02006c1ac3 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"GROW A FLYTRAP OR SUNFLOWER IN TIN\",\n",
       "                    \"value\": 2592\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"HAND WARMER BABUSHKA DESIGN\",\n",
       "                    \"value\": 2047\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"PACK OF 72 RETROSPOT CAKE CASES\",\n",
       "                    \"value\": 1856\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"PACK OF 12 LONDON TISSUES \",\n",
       "                    \"value\": 1617\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"72 SWEETHEART FAIRY CAKE CASES\",\n",
       "                    \"value\": 1114\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"SMALL POPCORN HOLDER\",\n",
       "                    \"value\": 1030\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"PACK OF 60 PINK PAISLEY CAKE CASES\",\n",
       "                    \"value\": 1015\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"WORLD WAR 2 GLIDERS ASSTD DESIGNS\",\n",
       "                    \"value\": 1011\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"60 TEATIME FAIRY CAKE CASES\",\n",
       "                    \"value\": 983\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"RED TOADSTOOL LED NIGHT LIGHT\",\n",
       "                    \"value\": 956\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"25%\",\n",
       "                \"55%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"79%\",\n",
       "                \"60%\"\n",
       "            ],\n",
       "            \"roseType\": \"radius\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"GROW A FLYTRAP OR SUNFLOWER IN TIN\",\n",
       "                \"HAND WARMER BABUSHKA DESIGN\",\n",
       "                \"PACK OF 72 RETROSPOT CAKE CASES\",\n",
       "                \"PACK OF 12 LONDON TISSUES \",\n",
       "                \"72 SWEETHEART FAIRY CAKE CASES\",\n",
       "                \"SMALL POPCORN HOLDER\",\n",
       "                \"PACK OF 60 PINK PAISLEY CAKE CASES\",\n",
       "                \"WORLD WAR 2 GLIDERS ASSTD DESIGNS\",\n",
       "                \"60 TEATIME FAIRY CAKE CASES\",\n",
       "                \"RED TOADSTOOL LED NIGHT LIGHT\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"left\": \"2%\",\n",
       "            \"top\": \"15%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"2010\\u5e74\\u5723\\u8bde\\u8282\\u524d\\u540e\\u7684\\u70ed\\u9500\\u5546\\u54c1\\u524d\\u5341\\u540d\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_5de5bf824d284159970bbe02006c1ac3.setOption(option_5de5bf824d284159970bbe02006c1ac3);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1335f990>"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pie=Pie().add(\n",
    "            \"\",\n",
    "            shop_Christmas_sales.values.tolist(),\n",
    "            radius=[\"25%\", \"55%\"],\n",
    "            center=[\"79%\", \"60%\"],\n",
    "            rosetype=\"radius\"\n",
    "        ).set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"2010年圣诞节前后的热销商品前十名\"),\n",
    "            legend_opts=opts.LegendOpts(\n",
    "                orient=\"vertical\", pos_top=\"15%\", pos_left=\"2%\"\n",
    "            )\n",
    "        )\n",
    "pie.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"62b75d0f341f418bb25926163f5e1ce2\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_62b75d0f341f418bb25926163f5e1ce2 = echarts.init(\n",
       "                    document.getElementById('62b75d0f341f418bb25926163f5e1ce2'), 'white', {renderer: 'canvas'});\n",
       "                var option_62b75d0f341f418bb25926163f5e1ce2 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"funnel\",\n",
       "            \"name\": \"\\u5546\\u54c1\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"WORLD WAR 2 GLIDERS ASSTD DESIGNS\",\n",
       "                    \"value\": 53215\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"ASSORTED COLOUR BIRD ORNAMENT\",\n",
       "                    \"value\": 35314\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"PACK OF 72 RETROSPOT CAKE CASES\",\n",
       "                    \"value\": 33409\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"POPCORN HOLDER\",\n",
       "                    \"value\": 30504\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"RABBIT NIGHT LIGHT\",\n",
       "                    \"value\": 27094\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"MINI PAINT SET VINTAGE \",\n",
       "                    \"value\": 25880\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"PACK OF 12 LONDON TISSUES \",\n",
       "                    \"value\": 25321\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"PACK OF 60 PINK PAISLEY CAKE CASES\",\n",
       "                    \"value\": 24163\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"BROCADE RING PURSE \",\n",
       "                    \"value\": 22960\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"VICTORIAN GLASS HANGING T-LIGHT\",\n",
       "                    \"value\": 21984\n",
       "                }\n",
       "            ],\n",
       "            \"sort\": \"descending\",\n",
       "            \"gap\": 0,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"MINI PAINT SET VINTAGE \",\n",
       "                \"PACK OF 72 RETROSPOT CAKE CASES\",\n",
       "                \"PACK OF 12 LONDON TISSUES \",\n",
       "                \"BROCADE RING PURSE \",\n",
       "                \"POPCORN HOLDER\",\n",
       "                \"WORLD WAR 2 GLIDERS ASSTD DESIGNS\",\n",
       "                \"ASSORTED COLOUR BIRD ORNAMENT\",\n",
       "                \"RABBIT NIGHT LIGHT\",\n",
       "                \"PACK OF 60 PINK PAISLEY CAKE CASES\",\n",
       "                \"VICTORIAN GLASS HANGING T-LIGHT\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"WORLD WAR 2 GLIDERS ASSTD DESIGNS\": true,\n",
       "                \"ASSORTED COLOUR BIRD ORNAMENT\": true,\n",
       "                \"PACK OF 72 RETROSPOT CAKE CASES\": true,\n",
       "                \"POPCORN HOLDER\": true,\n",
       "                \"RABBIT NIGHT LIGHT\": true,\n",
       "                \"MINI PAINT SET VINTAGE \": true,\n",
       "                \"PACK OF 12 LONDON TISSUES \": true,\n",
       "                \"PACK OF 60 PINK PAISLEY CAKE CASES\": true,\n",
       "                \"BROCADE RING PURSE \": true,\n",
       "                \"VICTORIAN GLASS HANGING T-LIGHT\": true\n",
       "            },\n",
       "            \"show\": false,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5168\\u5e74\\u5546\\u54c1\\u524d\\u5341\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_62b75d0f341f418bb25926163f5e1ce2.setOption(option_62b75d0f341f418bb25926163f5e1ce2);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x167b4db0>"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#漏斗图\n",
    "funnel=Funnel().add(\n",
    "        \"商品\",\n",
    "        shop_sales.values.tolist(),\n",
    "    ).set_global_opts(title_opts=opts.TitleOpts(title=\"全年商品前十\"),legend_opts=opts.LegendOpts(\n",
    "                is_show=False\n",
    "            ))\n",
    "funnel.render_notebook()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
